//
// Created by Administrator on 2025/3/25.
//

#ifndef MYTEST_07_CONCURRENCY_H
#define MYTEST_07_CONCURRENCY_H

// Learn with Examples, 2020, MIT license
#include <systemc>
using namespace sc_core;

SC_MODULE(CONCURRENCY) {
    SC_CTOR(CONCURRENCY) { // constructor
        SC_THREAD(thread1); // register thread1
        SC_THREAD(thread2); // register thread2
    }
    void thread1() {
        while(true) { // infinite loop
            std::cout << sc_time_stamp() << ": thread1" << std::endl;
            wait(2, SC_SEC); // trigger again after 2 "simulated" seconds
        }
    }
    void thread2() {
        while(true) {
            std::cout << "\t" << sc_time_stamp() << ": thread2" << std::endl;
            wait(3, SC_SEC);
        }
    }
};



#endif //MYTEST_07_CONCURRENCY_H
